<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>清除浮动</title>
    <!-- 方法1：通过BFC，-通过父元素增加overflow:hidden/overflow:auto来清楚浮动
     因为在计算BFC的高度时，子元素的float box也会参与计算 -->
    <style type="text/css">
        .box1 {
            /*为box1设置一个边框*/
            border: 10px red solid;
            overflow: hidden;

        }

        .box2 {
            width: 100px;
            height: 100px;
            background-color: blue;
            float: left;
        }

        .box3 {
            height: 100px;
            background-color: yellow;
        }
    </style>
</head>

<body>

    <div class="box1">
        <div class="box2"></div>
    </div>

    <div class="box3"></div>

</body>

</html>